package me.panpf.sketch.sample;
/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import me.panpf.sketch.uri.ApkIconUriModel;
import me.panpf.sketch.uri.AppIconUriModel;
import me.panpf.sketch.uri.DrawableUriModel;
import me.panpf.sketch.uri.OhosResUriModel;
import ohos.app.Context;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * AssetImage
 */
public class AssetImage {
    /**
     * TYPE_TEST_JPG
     */
    public static final String TYPE_TEST_JPG = "resources/rawfile/sample.jpg";

    /**
     * TYPE_TEST_PNG
     */
    public static final String TYPE_TEST_PNG = "resources/rawfile/sample.png";

    /**
     * TYPE_TEST_GIF
     */
    public static final String TYPE_TEST_GIF = "resources/rawfile/sample.gif";

    /**
     * TYPE_TEST_WEBP
     */
    public static final String TYPE_TEST_WEBP = "resources/rawfile/sample.webp";

    /**
     * TYPE_TEST_BMP
     */
    public static final String TYPE_TEST_BMP = "resources/rawfile/sample.bmp";

    /**
     * HUGE_CHANG_WEI_BO
     */
    public static final String HUGE_CHANG_WEI_BO = "sample/resources/rawfile/large_chang_wei_bo.jpg";

    /**
     * HUGE_QMSHT
     */
    public static final String HUGE_QMSHT = "sample/resources/rawfile/large_qing_ming_shang_he_tu.jpg";

    /**
     * HUGE_CARD
     */
    public static final String HUGE_CARD = "sample/resources/rawfile/large_card.png";

    /**
     * HUGE_WORLD_MAP
     */
    public static final String HUGE_WORLD_MAP = "sample/resources/rawfile/large_world_map.jpg";

    /**
     * MEI_NV
     */
    public static final String MEI_NV = "resources/rawfile/mei_nv.jpg";

    /**
     * MASK
     */
    public static final String MASK = "resources/rawfile/mask.png";

    /**
     * URI_TEST_ANDR_RES_BY_NAME
     */
    public static final String URI_TEST_ANDR_RES_BY_NAME = OhosResUriModel.makeUriByName("base", "graphic", "ic_play"); // todo 支持 svg 图片

    /**
     * URI_TEST_ANDR_RES_BY_NAME2
     */
    public static final String URI_TEST_ANDR_RES_BY_NAME2 = OhosResUriModel.makeUriByName(BuildConfig.PACKAGE_NAME, "mipmap", "ic_launcher");

    /**
     * URI_TEST_ANDR_RES_BY_ID
     */
    public static final String URI_TEST_ANDR_RES_BY_ID = OhosResUriModel.makeUriById(BuildConfig.PACKAGE_NAME, ResourceTable.Media_ic_launcher);

    /**
     * URI_TEST_ANDR_RES_BY_NAME3
     */
    public static final String URI_TEST_ANDR_RES_BY_NAME3 = OhosResUriModel.makeUriByName("com.ohos.settings", "drawable", "ic_launcher");

    /**
     * URI_TEST_APP
     */
    public static final String URI_TEST_APP = AppIconUriModel.makeUri(BuildConfig.PACKAGE_NAME, BuildConfig.VERSION_CODE);

    /**
     * URI_TEST_ASSET
     */
    public static final String URI_TEST_ASSET = "resources/rawfile/mei_nv.jpg";

    /**
     * URI_TEST_DRAWABLE
     */
    public static final String URI_TEST_DRAWABLE = DrawableUriModel.makeUri(ResourceTable.Media_ic_launcher);

    /**
     * IN_BITMAP_SAMPLES
     */
    public static final String[] IN_BITMAP_SAMPLES = new String[]{
            TYPE_TEST_JPG,
            TYPE_TEST_PNG,
            TYPE_TEST_GIF,
            TYPE_TEST_WEBP,
            TYPE_TEST_BMP,
    };

    /**
     * HUGE_IMAGES
     */
    public static final List<String> HUGE_IMAGES = new ArrayList<>();

    /**
     * URI_TEST_BASE64
     */
    public static final String URI_TEST_BASE64 = "";

    /**
     * getAll
     *
     * @param context
     * @return String[]
     */
    public static String[] getAll(Context context) {
        ArrayList<String> stringList = new ArrayList<>();
        Collections.addAll(stringList, TYPE_TEST_JPG,
                TYPE_TEST_PNG,
                TYPE_TEST_GIF,
                TYPE_TEST_WEBP,
                TYPE_TEST_BMP,

                HUGE_WORLD_MAP,
                HUGE_QMSHT,
                HUGE_CHANG_WEI_BO,
                HUGE_CARD,

                MEI_NV,
                MASK,
                context.getString(ResourceTable.String_chunk),
                context.getString(ResourceTable.String_chunk2));
        Collections.addAll(stringList, getTestUris());
        Collections.addAll(stringList, ROTATE_90,
                ROTATE_180,
                ROTATE_270,
                FLIP_HORIZONTAL,
                TRANSPOSE,
                FLIP_VERTICAL,
                TRANSVERSE);
        return stringList.toArray(new String[stringList.size()]);
    }

    /**
     * getTestUris
     *
     * @return String[]
     */
    public static String[] getTestUris() {
        return new String[]{
                URI_TEST_ASSET,
                "resources/rawfile/ic_launcher.png",
                "resources/rawfile/ic_launcher.png",
                URI_TEST_ANDR_RES_BY_NAME,
                "resources/rawfile/ic_launcher.png",
                "resources/rawfile/ic_launcher.png",
                URI_TEST_ANDR_RES_BY_NAME3,
                URI_TEST_BASE64,
                URI_TEST_DRAWABLE
        };
    }

    /**
     * ROTATE_90
     */
    public static final String ROTATE_90 = "resources/rawfile/TEST_FILE_NAME_ROTATE_90.jpg";

    /**
     * ROTATE_180
     */
    public static final String ROTATE_180 = "resources/rawfile/TEST_FILE_NAME_ROTATE_180.jpg";

    /**
     * ROTATE_270
     */
    public static final String ROTATE_270 = "resources/rawfile/TEST_FILE_NAME_ROTATE_270.jpg";

    /**
     * FLIP_HORIZONTAL
     */
    public static final String FLIP_HORIZONTAL = "resources/rawfile/TEST_FILE_NAME_FLIP_HORIZONTAL.jpg";

    /**
     * TRANSPOSE
     */
    public static final String TRANSPOSE = "resources/rawfile/TEST_FILE_NAME_TRANSPOSE.jpg";

    /**
     * FLIP_VERTICAL
     */
    public static final String FLIP_VERTICAL = "resources/rawfile/TEST_FILE_NAME_FLIP_VERTICAL.jpg";

    /**
     * TRANSVERSE
     */
    public static final String TRANSVERSE = "resources/rawfile/TEST_FILE_NAME_TRANSVERSE.jpg";

    static {
        HUGE_IMAGES.add(HUGE_WORLD_MAP);
        HUGE_IMAGES.add(HUGE_QMSHT);
        HUGE_IMAGES.add(HUGE_CHANG_WEI_BO);
        HUGE_IMAGES.add(HUGE_CARD);
    }

}
